package com.atguigu.gmall.task.job;

import com.atguigu.gmall.common.constant.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * title:
 * author: Gyh
 * date:2023-05-14 9:09
 * Description:
 */
@Slf4j
@Component
public class SeckillJob {

    @Autowired
    private RabbitService rabbitService;

    @XxlJob("myjob")
    public void testJob(){
        log.info("my job running...");
    }

    /**
     * 定时任务
     * 每天凌晨1点发送消息,触发秒杀商品预热
     * 测试中每隔5s执行一次
     */
    @XxlJob("sendImpSeckGoodsMsg")
    public void sendImpSeckGoodsMsg(){
        log.info("[任务服务]执行发送秒杀商品入库消息");
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_1,"");

    }
}
